{extend name="layout/detail" /}

{block name="content"}
<input type="hidden" name="ajax" id="ajax" value="1">
<div class="td-content-wrap p20">
    <div class="td-content-header">
        <h1>编辑菜单</h1>
    </div>
    <hr>
    <div class="space-20"></div>
    <form id="form_data" class="layui-form" method="post" action="{:url('save')}">
        <input type="hidden" name="opmode" value="edit">
        <input type="hidden" name="id" id="id" value="{$menu.id}">
        <div class="layui-form-item">
            <label class="layui-form-label required">名称：</label>
            <div class="layui-input-block w19">
                <input type="text" name="name" placeholder="请输入名称" class="layui-input" check="required" info="请输入名称"
                       value="{$menu.name}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label required">上级菜单：</label>
            <div class="layui-input-block w19">
                <input type="hidden" id="pid" name="pid" value="{$menu.pid}">
                <input type="text" id="pid_name" name="pid_name" placeholder="请选择上级菜单" class="layui-input"
                       check="required"
                       info="请选择上级菜单" readonly="readonly" value="{$pid_name}">
                <a class="add-on" onclick="select_pid();"><i class="fa fa-search"></i></a>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">URL：</label>
            <div class="layui-input-block w38">
                <input type="text" name="url" placeholder="请输入URL" class="layui-input" value="{$menu.url}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">统计：</label>
            <div class="layui-input-block w38">
                <input type="text" name="badge" class="layui-input" value="{$menu.badge}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">图标：</label>
            <div class="layui-input-inline">
                <input type="text" name="icon" placeholder="请输入图标" class="layui-input" value="{$menu.icon}">
            </div>
            <div class="layui-form-mid">
                <i class="{$menu.icon}"></i>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">排序：</label>
            <div class="layui-input-block w6">
                <input type="text" name="sort" class="layui-input" value="{$menu.sort}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">状态：</label>
            <div class="layui-input-block w10">
                <select name="is_del" class="layui-input">
                    <option value="0" {eq name="$menu.is_del" value="0" }selected="selected" {
                    /eq}>启用</option>
                    <option value="1" {eq name="$menu.is_del" value="1" }selected="selected" {
                    /eq}>禁用</option>
                </select>
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">备注：</label>
            <div class="layui-input-block">
                <textarea name="remark" class="layui-textarea">{$menu.remark}</textarea>
            </div>
        </div>
        <hr>
        <div class="layui-form-item">
            <label class="layui-form-label"></label>
            <div class="layui-input-block">
                <a class="layui-btn" lay-submit="" lay-filter="demo2" onclick="save();">保存</a>
                <a class="layui-btn layui-btn-primary" onclick="go_return_url();">取消</a>
            </div>
        </div>
    </form>
    {/block}

    {block name="script"}
    <script>
        layui.use(['form'], function () {
            var fn = {
                select_pid: function () {
                    popup_open("{:url('select_pid')}?module={$module}", 560, 470);
                },
                save: function () {
                    send_form("form_data", "{:url('save')}", function (ret) {
                        if (ret.code) {
                            layer.msg(ret.msg, {
                                time: 1200
                            }, function () {
                                location.href = "{:url('index')}";
                            });
                        } else {
                            layer.msg(ret.msg);
                            return false;
                        }
                    });
                }
            };
            win_exp(fn);

        });
    </script>
    {/block}
